<template>
  <div>
    <!-- 面包屑导航 -->
    <breadcrumb-nav>
      <template v-slot:firstMenu>身份认证</template>
      <template v-slot:secondMenu>实名认证</template>
    </breadcrumb-nav>

    <!-- 卡片视图 -->
    <el-card>
      <rights-table :data-list="rightsList" @update-list="getList"></rights-table>
      <Pagination :query-info="queryInfo" :total="total" @page-size-change="handleSizeChange"
                    @current-page-change="handlePageChange"/>
    </el-card>
  </div>
</template>

<script>

  import BreadcrumbNav from "../common/BreadcrumbNav";
  import Pagination from "../common/Pagination.vue";

  import RightsTable from "@/components/rights/ChildComponents/RightsTable.vue";
  import {getFarmerPageRequest} from "@/network/rights";

  export default {
    name: "Rights",
    components:{
      RightsTable,
      Pagination,
      BreadcrumbNav
    },
    data() {
      return {
        rightsList: [],
        type:0,
        queryInfo: {
          pageNo: 1, // 当前页
          pageSize: 5 // 每页显示多少条数据
        },
        total: 0
      }
    },
    created() {
      this.getList();
    },
    methods: {
      async getList(){
        const {type,queryInfo:{pageNo,pageSize}} = this
        const {data:{list,total},code,msg} = await getFarmerPageRequest(type,pageNo,pageSize)
        if (code !== 200) return this.$errorMessage(msg);
        this.rightsList = list;
        this.setTotal(total)
      },
      setTotal(total){
        this.total = Number(total)
      },
      handleSizeChange(size) {
        this.queryInfo.pageSize = size
        this.$nextTick(this.getList)
      },
      handlePageChange(page) {
        this.queryInfo.pageNum = page
        this.$nextTick(this.getList)
      },
    }
  }
</script>

<style scoped>

</style>
